<?php

ini_set('display_errors', 1);
error_reporting(-1);
ini_set('memory_limit', '2048M');
require_once '/data/wwwroot/g_vendor/autoload.php';

$date = date('Y-m-d', time());

$scene = \Biz\service\springHomeDecActivity\ActivityPushService::getScene($date);

if (!$scene) {
    echo "当前日期无提醒！" . PHP_EOL;
    exit;
}

$lastUid = 0;

$modCount = $argv[1] ?? 2;

$modValue = $argv[2] ?? 0;

$limitCount = $argv[3] ?? 2000;

$params = [$lastUid, $modCount, $modValue, $limitCount];

$list = \Biz\service\springHomeDecActivity\ActivityUserGroupService::getUids($scene, $params);

$total = 0;

while (is_array($list) && count($list) > 0) {

    echo sprintf("query res count:%d \r\n", count($list));

    $total = $total + count($list);

    foreach ($list as $item) {
        \Biz\service\springHomeDecActivity\ActivityPushService::push($item[0], $date);
    }
    if (count($list) < $limitCount) {
        break;
    }
    $lastRecord = array_pop($list);
    $params[0] = $lastRecord[0];
    $list = \Biz\service\springHomeDecActivity\ActivityUserGroupService::getUids($scene, $params);
    if (!($list && is_array($list) && count($list) > 0)) {
        break;
    }
}

var_dump("push count:" . $total);

exit;
